package com.xmut.servicebase.exceptionhandler;


/**
 * 处理特定异常
 */

import com.xmut.commonutils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 处理特定异常类
 */
@ControllerAdvice
public class ArithmeticExceptionHandler {

    // 指定出现森么异常执行这个方法
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public R error(ArithmeticException e) {
        e.printStackTrace();

        return R.error().message("执行了特定异常处理");
    }
}